package cn.kbyue.exceptiondemo.common;

import cn.kbyue.exceptiondemo.common.enums.CommonResponseEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 类名可简写为 R 方便使用
 * @param <T>
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class CommonResponse<T> extends BaseResponse {
    private T data;

    public static <T> CommonResponse<T> success(T data) {
        CommonResponse<T> response = new CommonResponse<>();
        response.setCode(CommonResponseEnum.SUCCESS.getCode());
        response.setMessage(CommonResponseEnum.SUCCESS.getMessage());
        response.setData(data);
        return response;
    }
}
